Skip to content

Added JUnit Test Cases for Replacement #1268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

surajdm123
Copy link
Contributor

@surajdm123 surajdm123 commented Jul 3, 2025

Changes

This PR adds the missing unit test case for Replacement.

Before:
Screenshot 2025-07-16 at 10 26 05 PM

After:
Screenshot 2025-07-16 at 10 24 41 PM

Test Plan

mvn -Dtest=ReplacementTest test

...
[INFO] Running com.google.googlejavaformat.java.ReplacementTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.068 s - in com.google.googlejavaformat.java.ReplacementTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

mvn test

[INFO] Results:
[INFO] 
[INFO] Tests run: 1533, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.168 s
[INFO] Finished at: 2025-07-16T22:30:47-07:00
[INFO] ------------------------------------------------------------------------

Next Steps

  • Add more missing test cases to make this codebase more resilient.

@surajdm123
Copy link
Contributor Author

@cushon Can you please review this?

@surajdm123
Copy link
Contributor Author

surajdm123 commented Jul 16, 2025

@cushon , would you be able to help with this please? 🙏

@Pankraz76

This comment was marked as resolved.

@jbduncan
Copy link
Contributor

@Pankraz76 OpenRewrite has its own flaws, too, like a slow Gradle plugin and a not-fully open source ecosystem of recipes, so I'd recommend google-java-format or Palantir's fork for formatting purposes in the meantime.

@Pankraz76

This comment was marked as resolved.

@Pankraz76
Copy link

sorry my not being nice and patient it seems all fine. Maybe just vacay or something.

Please excuse and enjoy.

Copy link
Collaborator

@cushon cushon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@surajdm123 can you say more about the goal here, and why you decided to add these specific tests? There is some indirect coverage of Replacement from other tests, did you find issues with it you'd like to change as a follow-up?

@surajdm123
Copy link
Contributor Author

surajdm123 commented Jul 17, 2025

@surajdm123 can you say more about the goal here, and why you decided to add these specific tests? There is some indirect coverage of Replacement from other tests, did you find issues with it you'd like to change as a follow-up?

@cushon
Thank you so much for reviewing the code and providing valuable feedback.
While going through the Replacement class, I noticed that a few important lines weren’t covered by existing tests, so I’ve added additional test cases to improve the coverage.

Before:
Screenshot 2025-07-16 at 10 26 05 PM

After:
Screenshot 2025-07-16 at 10 24 41 PM

@surajdm123
Copy link
Contributor Author

@cushon
I've addressed all the feedback in the latest commit. Whenever you have a moment, I'd appreciate it if you could take another look.
Thank you again for your time and insightful feedback!

copybara-service bot pushed a commit that referenced this pull request Jul 17, 2025
### Changes

This PR adds the missing unit test case for Replacement.

**Before:**
<img width="938" height="315" alt="Screenshot 2025-07-16 at 10 26 05 PM" src="https://github.com/user-attachments/assets/47a08af5-b240-40ba-8abf-9f20dce46c22" />

**After:**
<img width="947" height="315" alt="Screenshot 2025-07-16 at 10 24 41 PM" src="https://github.com/user-attachments/assets/2a18ffca-0b75-4e18-b071-7246c438ce29" />

### Test Plan

> mvn -Dtest=ReplacementTest test

```
...
[INFO] Running com.google.googlejavaformat.java.ReplacementTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.068 s - in com.google.googlejavaformat.java.ReplacementTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
```
----

> mvn test

```
[INFO] Results:
[INFO]
[INFO] Tests run: 1533, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.168 s
[INFO] Finished at: 2025-07-16T22:30:47-07:00
[INFO] ------------------------------------------------------------------------

```

### Next Steps

- Add more missing test cases to make this codebase more resilient.

Fixes #1268

FUTURE_COPYBARA_INTEGRATE_REVIEW=#1268 from surajdm123:add-test 1bad87c
PiperOrigin-RevId: 784305506
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants